<!--
 * @Autor: dingxiaolin
 * @Date: 2021-05-13 17:12:38
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-05-18 10:54:36
-->
<template>
    <div class="select">
        <div @click="showModel = true" class="color" style="position: relative">{{ modelType }} <i class="sanjiao"></i></div>
        <van-popup v-model:show="showModel" round position="bottom">
            <van-picker
                title="选择机型"
                :columns="props.modelList"
                @cancel="showModel = false"
                :defaultIndex="defaultModel"
                @confirm="confirmModel"
            />
        </van-popup>
    </div>
</template>

<script lang="ts">
import { defineComponent, PropType, reactive, toRefs, inject, computed, nextTick, onMounted } from 'vue';
import { useRouter } from 'vue-router';

export default defineComponent({
    name: 'Model',
    components: {},
    props: { modelList: Array },
    emits: ['emit'],
    setup(props, ctx) {
        const router = useRouter();
        const state = reactive({
            showModel: false,
            defaultModel: 0,
            modelType: '全部',
        });
        onMounted(() => {});
        function confirmModel(value, index) {
            state.modelType = value;
            state.showModel = false;
            ctx.emit('emit', state.modelType);
        }
        return {
            ...toRefs(state),
            confirmModel,
            props,
        };
    },
});
</script>

<style lang="scss" scoped>
</style>
